<template>
    <div class="app-container">
        <el-form :model="queryParams" inline label-width="90px">
            <el-form-item prop="name" label="姓名">
                <el-input style="width:240px;" v-model="queryParams.name" placeholder="请输入姓名" />
            </el-form-item>
            <el-form-item prop="phone" label="电话">
                <el-input style="width:240px;" v-model="queryParams.phone" placeholder="请输入电话" />
            </el-form-item>
            <el-form-item>
                <el-button :loading="loading" type="primary" @click="handleQuery">搜索</el-button>
                <el-button :loading="loading" @click="handleReset">重置</el-button>
            </el-form-item>
        </el-form>
        <el-table :data="dataList" :loading="loading">
            <el-table-column show-overflow-tooltip align="center" prop="name" label="姓名" width="120" />
            <el-table-column show-overflow-tooltip align="center" prop="nickname" label="微信昵称" width="120" />
            <el-table-column show-overflow-tooltip align="center" prop="phone" label="电话" width="120" />
            <el-table-column show-overflow-tooltip align="center" prop="sex" label="微信性别"
                :formatter="row => sexEnum[row.sex]" />
            <el-table-column show-overflow-tooltip align="center" prop="isMarket" label="是否添加营销数据" width="130"
                :formatter="row => isNoEnum[row.isMarket]" />
            <el-table-column show-overflow-tooltip align="center" prop="enterpriseCount" label="合计服务企业数" width="120" />
            <el-table-column show-overflow-tooltip align="center" prop="lastYeaer" label="近一年服务企业数" width="140" />
            <el-table-column show-overflow-tooltip align="center" prop="lastMonth" label="近一个月服务企业数" width="150" />
            <el-table-column show-overflow-tooltip align="center" prop="shareCustomerUrl" label="分享客二维码地址" width="150" />
            <el-table-column show-overflow-tooltip align="center" prop="sharePartnerUrl" label="分享合作伙伴二维码地址" width="180" />
        </el-table>
        <pagination v-show="total > 0" :total="total" v-model:page="queryParams.pageNo" v-model:limit="queryParams.pageSize"
            @pagination="getList" />
    </div>
</template>

<script setup name="UserInfoManage">
import { getUserInfoList } from '@/api/userInfoManage';
import { sexEnum, isNoEnum } from '@/utils/enum';
const { proxy } = getCurrentInstance()
const queryParams = ref({
    pageNo: 1,
    pageSize: 10,
})
const total = ref(0)
const loading = ref(false)
const dataList = ref([])

getList()
function getList() {
    const reqForm = JSON.parse(JSON.stringify(queryParams.value))
    loading.value = true
    getUserInfoList(reqForm).then(res => {
        dataList.value = res.data || []
        total.value = res.totalCount
    }).finally(() => loading.value = false)
}
function handleQuery() {
    queryParams.value.pageNo = 1
    getList()
}
function handleReset() {
    queryParams.value = {
        pageNo: 1,
        pageSize: 10,
    }
    getList()
}

</script>

<style lang="scss" scoped></style>